package cn.pn.project.controller;

import cn.pn.project.client.base.CityFeign;
import cn.pn.project.common.Dto;
import cn.pn.project.common.DtoUtil;
import cn.pn.project.pojo.base.City;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/city")
public class CityController {
    @Autowired
    private CityFeign cityFeign;
    /**
     * 查询全部城市并实现按字母展示数据
     * @return
     */
    @RequestMapping(value = "/mapCity",method = RequestMethod.POST)
    public Dto<City> mapCity() throws Exception {
        System.out.println("-------------------执行consumer中的mapCity方法-------------------");
        Map<String,List<City>> cities;
        cities=cityFeign.mapCity();
        if(cities!=null){
            return DtoUtil.returnDataSuccess(cities);
        }else{
            return DtoUtil.returnFail("获取数据失败","6002");
        }
    }
    /**
     * 查询热门城市（根据销售量,调订单接口）
     */
    public String listHotCity(){
        return null;
    }
}
